-- procedure separee
with Ada.Text_Io;

separate (Dictionnaires)
procedure Supprime_Mots(F: in out Ada.Text_Io.File_Type; Dico: in out Dictionnaire) is

   -- format du fichier
   -- <mot : que des lettres> (separateur = autre chose qu'une lettre)
   -- <definition> (fin de ligne)
   procedure Avale_Espace (C_valide: out Boolean; C: out Character) is
   begin
      C:=' ';
      loop
         exit when Ada.Text_Io.End_Of_File(F);
         if Ada.Text_Io.End_Of_Line(F) then
            Ada.Text_Io.Skip_Line(F);
         else
            Ada.Text_Io.Get_Immediate(F, C);
            exit when C/=' ';
         end if;
      end loop;
      C_valide := C/=' ';
   end Avale_Espace;

   function Get_Mot return String is
      Lg: Natural := 0;
      C: Character;
      ok: Boolean;
      Res: String(1..Lg_Max_Mot);
   begin
      Avale_Espace(ok, C);
      if Ok then Lg:= Lg+1; Res(Lg):=C; end if;
      loop
         exit when Ada.Text_Io.End_Of_File(F);
         Ada.Text_Io.Get_Immediate(F, C);
         exit when (C not in  'a'..'z') and (C not in 'A'..'Z');
         Lg:= Lg+1; Res(Lg):=C;
      end loop;
      return Res(1..Lg);
   exception
      when Constraint_Error => return Res;
   end Get_Mot;

   function Get_Def return String is
      Lg: Natural := 0;
      C: Character;
      Ok: Boolean;
      Res: String(1..Lg_Max_Def);
   begin
      Avale_Espace(Ok, C);
      if Ok then Lg:= Lg+1; Res(Lg):=C; end if;
      loop
         exit when Ada.Text_Io.End_Of_File(F)
           or else Ada.Text_Io.End_Of_Line(F);
         Ada.Text_Io.Get_Immediate(F, C);
         Lg:= Lg+1; Res(Lg):=C;
      end loop;
      return Res(1..Lg);
   exception
      when Constraint_Error => Ada.Text_Io.Skip_Line(F); Return Res;
   end Get_Def;

   M: Mot; Def: Definition;
   Trouve: Boolean;
begin
   Ada.Text_Io.Reset(F);
   loop
      exit when Ada.Text_Io.End_Of_File(F);
      M:= Cree_Mot(Get_Mot);
      Def := Cree_Def(Get_Def);
      Supprime(Dico, M, Trouve, Def);
   end loop;
end Supprime_Mots;
